import { HarmonyPilotCommentCollection } from "./HarmonyPilotCommentCollection";
import * as vscode from 'vscode';
export class HarmonyPilotCommentCollectionProvider {
	private static threadUuidToCollectionMap: Map<string, HarmonyPilotCommentCollection> = new Map<string, HarmonyPilotCommentCollection>();

	private static threadToUuidMap: Map<vscode.CommentThread, string> = new Map<vscode.CommentThread, string>();


	public static getCollection(threadUuid: string): HarmonyPilotCommentCollection | undefined {
		return HarmonyPilotCommentCollectionProvider.threadUuidToCollectionMap.get(threadUuid);
	}

	public static addCollection(threadUuid: string, collection: HarmonyPilotCommentCollection) {
		HarmonyPilotCommentCollectionProvider.threadUuidToCollectionMap.set(threadUuid, collection);
	}


	public static addThreadToUuid(thread: vscode.CommentThread, threadUuid: string) {
		HarmonyPilotCommentCollectionProvider.threadToUuidMap.set(thread, threadUuid);
	}

	public static getUuidByThread(thread: vscode.CommentThread): string | undefined {
		return HarmonyPilotCommentCollectionProvider.threadToUuidMap.get(thread);
	}

	/**
	 * 清理HarmonyPilotCommentCollectionProvider中的相关数据
	 * @param thread 
	 */
	public static removeThread(thread: vscode.CommentThread) {
		const threadUuid = HarmonyPilotCommentCollectionProvider.threadToUuidMap.get(thread);
		if (threadUuid) {
			HarmonyPilotCommentCollectionProvider.threadUuidToCollectionMap.delete(threadUuid);
		}
		HarmonyPilotCommentCollectionProvider.threadToUuidMap.delete(thread);
	}
}

